import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);

const store = new Vuex.Store({
	state: {
		wxcode: null,
		token: null,
		user: {
			id: '',
			avatar: '',
			nickname: '',
			role: 0
		},
		siteInfo: {
			logo: '',
			web_name: '',
			ICP: '',
			copyright: '',
			version: '',
			tech_support: '',
			rela_link: []
		}
	},
	mutations: {
		setWxCode(state, code) {
			state.wxcode = code
		},
		setToken(state, token) {
			state.token = token
		},
		setUserInfo(state, userInfo) {
			state.user.id = userInfo.id
			state.user.avatar = userInfo.avatar
			state.user.nickname = userInfo.nickname
		},
		setSiteInfo(state, siteInfo) {
			state.siteInfo.logo = siteInfo.logo
			state.siteInfo.web_name = siteInfo.web_name
			state.siteInfo.ICP = siteInfo.ICP
			state.siteInfo.copyright = siteInfo.copyright
			state.siteInfo.version = siteInfo.version
			state.siteInfo.tech_support = siteInfo.tech_support
			state.siteInfo.rela_link = siteInfo.rela_link
		}
	}
})
export default store